home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / clisp-li.000 / clisp-li / clisp-1996-07-22 / linkkit / module.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  2.7 KB  |  75 lines

  1. // This is C++ code.
  2.  
  3. // For each module this file is to be compiled with -DMODULE=modulename
  4. // and linked to the code of the module proper.
  5.  
  6. // This file provides an initializer which gets called by __main when the
  7. // program starts up - in case of statically linked modules - or when the
  8. // module gets loaded - in case of dynamically loaded modules.
  9.  
  10. // Idea by Marcus Daniels.
  11. // Bruno Haible 18.12.1994
  12.  
  13. // Tell clisp.h not to emit "register asm" declarations, since g++ doesn't
  14. // like them: "global register variable follows a function definition".
  15. // We are allowed to do disable them here because all the code in this file
  16. // is executed at a time when CLISP's global register variables have not yet
  17. // been initialized.
  18. #define IN_MODULE_CC
  19.  
  20. #ifdef NO_CLISP_H
  21. #include "lispbibl.c"
  22. #else
  23. #include "clisp.h"
  24. #endif
  25.  
  26. #ifdef DYNAMIC_MODULES
  27.  
  28. extern "C" subr_ CONCAT3(module__,MODULE,__subr_tab)[];
  29. extern "C" uintC CONCAT3(module__,MODULE,__subr_tab_size);
  30.  
  31. // Assume a struct consisting of objects has the same shape than an array of objects.
  32. extern "C" object CONCAT3(module__,MODULE,__object_tab)[];
  33. extern "C" uintC CONCAT3(module__,MODULE,__object_tab_size);
  34.  
  35. extern "C" subr_initdata CONCAT3(module__,MODULE,__subr_tab_initdata)[];
  36. extern "C" object_initdata CONCAT3(module__,MODULE,__object_tab_initdata)[];
  37. extern "C" void CONCAT3(module__,MODULE,__init_function_1) (module_ * module);
  38. extern "C" void CONCAT3(module__,MODULE,__init_function_2) (module_ * module);
  39.  
  40. static module_ this_module = {
  41.   /* name */           STRINGIFY(MODULE),
  42.   /* stab */           & CONCAT3(module__,MODULE,__subr_tab) [0],
  43.   /* stab_size */      & CONCAT3(module__,MODULE,__subr_tab_size),
  44.   /* otab */           & CONCAT3(module__,MODULE,__object_tab) [0],
  45.   /* otab_size */      & CONCAT3(module__,MODULE,__object_tab_size),
  46.   /* initialized */    FALSE,
  47.   /* stab_initdata */  & CONCAT3(module__,MODULE,__subr_tab_initdata) [0],
  48.   /* otab_initdata */  & CONCAT3(module__,MODULE,__object_tab_initdata) [0],
  49.   /* initfunction1 */  & CONCAT3(module__,MODULE,__init_function_1),
  50.   /* initfunction2 */  & CONCAT3(module__,MODULE,__init_function_2),
  51.   /* next */           NULL
  52. };
  53.  
  54. // Now this is really getting C++.
  55. // The only effect of this is to achieve that
  56. //   add_module(&this_module);
  57. // gets called at startup time or load time.
  58.  
  59. #define CLASSNAME  CONCAT3(module__,MODULE,__initializer_class)
  60.  
  61. class CLASSNAME
  62.   { public:
  63.       // Constructor, must have the same name as the class.
  64.       // Its return type defaults to the class, not `int' or `void'.
  65.       CLASSNAME (void);
  66.   };
  67.  
  68. CLASSNAME::CLASSNAME (void)
  69. { add_module(&this_module); }
  70.  
  71. static CLASSNAME CONCAT3(module__,MODULE,__initializer_dummy);
  72.  
  73. #endif
  74.  
  75.